unit Unit33; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, DbCtrls,
  StdCtrls, sqldb, db, Unit1;

type

  { TForm33 }

  TForm33 = class(TForm)
    Button1: TButton;
    Datasource1: TDatasource;
    DBComboBox1: TDBComboBox;
    Label1: TLabel;
    SQLQuery1: TSQLQuery;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
  public
    familia_producto : String;
  end; 

var
  Form33: TForm33; 

implementation

{ TForm33 }

procedure TForm33.FormShow(Sender: TObject);
begin
  familia_producto := '';

  if SQLQuery1.Active = True then
    SQLQuery1.Close;
    
  SQLQuery1.DataBase := Form1.PQConnection1;
  SQLQuery1.Transaction := Form1.SQLTransaction1;
  SQLQuery1.SQL.Text := 'select fmp_nombre from familia_producto order by fmp_nombre';
  
  SQLQuery1.Open;
  
  DBComboBox1.DataField := 'fmp_nombre';
  DBComboBox1.Clear;
  
  while not SQLQuery1.EOF do
  begin
    DBComboBox1.Items.Add(SQLQuery1.Fields[0].AsString);
    SQLQuery1.Next;
  end;
  
  DBComboBox1.Text := '';
  DBComboBox1.SetFocus;
end;

procedure TForm33.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  if SQLQuery1.Active = True then
    SQLQuery1.Close;
end;

procedure TForm33.Button1Click(Sender: TObject);
begin
  familia_producto := DBComboBox1.Text;
  Close;
end;

initialization
  {$I unit33.lrs}

end.

